package com.topnav.mc.admin.view.device;

import com.baomidou.mybatisplus.annotation.TableName;
import com.topnav.mc.admin.entity.Device;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;
import lombok.extern.slf4j.XSlf4j;
import org.springframework.beans.BeanUtils;
//import org.apache.commons.beanutils.BeanUtils;

import java.util.Date;
@Data
@TableName("mc_device_view")
@Slf4j
public class DeviceView {
    private Long id;
    private String note;
    private Date createTime;
    private Date updateTime;
    private String createBy;
    private String updateBy;

    private String code;
    private String name;
    /**  类型：1、 普能执法仪，2、4G执法仪, 3、监控摄像头 */
    private Integer cate;
    private Integer type;
    private Long orgId;
    private String path;
    private Long userId;
    private Long gbServerId;
    private String defaultChannel;
    private String defaultAlarmChannel;
    /**  状态：1、正常，2、报废, 3、维修 */
    private Integer state;
    //private Boolean subscriberPosition;

    /**
     * 不能用 BeanUtils.copyProperties();
     * 据说是因为 @Data 的原因
     **/
    public Device assignTo(Device dest){
        try{

            if (dest == null){
                dest = new Device();
            }
            dest.setId(this.getId());
            dest.setNote(this.getNote());
            dest.setCreateTime(this.getCreateTime());
            dest.setUpdateTime(this.getUpdateTime());

            dest.setCode(this.getCode());
            dest.setName(this.getName());
            dest.setType(this.getType());
            dest.setOrgId(this.getOrgId());
            dest.setGbServerId(this.getGbServerId());
            dest.setDefaultChannel(this.getDefaultChannel());
            dest.setDefaultAlarmChannel(this.getDefaultAlarmChannel());
            dest.setState(this.getState());
            //dest.setSubscriberPosition(this.getSubscriberPosition());
            return dest;
        }catch(Exception e){
            log.error(">>>>>>> DeviceView=>device:{} ",e);
        }
        return null;
    }
    public void assign(Device source){
        try{
            this.setId(source.getId());
            this.setNote(source.getNote());
            this.setCreateTime(source.getCreateTime());
            this.setUpdateTime(source.getUpdateTime());

            this.setCode(source.getCode());
            this.setName(source.getName());
            this.setType(source.getType());
            this.setOrgId(source.getOrgId());
            this.setGbServerId(source.getGbServerId());
            this.setDefaultChannel(source.getDefaultChannel());
            this.setDefaultAlarmChannel(source.getDefaultAlarmChannel());
            this.setState(source.getState());
            //this.setSubscriberPosition(source.getSubscriberPosition());
        }catch(Exception e){
            log.error(">>>>>>> device=>DeviceView:{} ",e);
        }
    }


}
